#! /bin/sh -vx
# $Id: triptest.test 53154 2019-12-17 19:06:20Z karl $
# Copyright 2017-2021 Karl Berry <tex-live@tug.org>
# Copyright 2009-2014 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

LC_ALL=C; export LC_ALL;  LANGUAGE=C; export LANGUAGE
+ LC_ALL=C
+ export LC_ALL
+ LANGUAGE=C
+ export LANGUAGE

testdir=$abs_srcdir/triptrap
+ testdir=SRCDIR/triptrap
TEXMFCNF=$testdir; export TEXMFCNF
+ TEXMFCNF=SRCDIR/triptrap
+ export TEXMFCNF

rm -rf tripdir
+ rm -rf tripdir
mkdir tripdir
+ mkdir tripdir
cd tripdir
+ cd tripdir
mkdir a b
+ mkdir a b

# See triptrap/README for explanation of why we believe these diffs are ok.

# TeX Live generic
cat >filter <<-\_EOF
	s,^\*\*(\./trip\.tex ##,** \&trip  trip \
	(trip.tex ##,
	s/ (TeX Live 20[^)]*)//
	s/(preloaded format=tex)/(INITEX)/
	s/format=trip [^)][^)]*)/format=trip)/
	s/)  [0-9A-Z: ]*$/)/
	s,^(\./,(,
	s/[1-9][0-9]* strings out of [1-9].*/XX strings out of YYY/
	s/[1-9][0-9]* string characters out of [1-9].*/XXX string characters out of YYYY/
	s/sequences out of [1-9].*/sequences out of YYYY/
	s/[1-9] hyphenation exceptions* out of [1-9].*/X hyphenation exceptions out of YYY/
	s/[1-9][0-9]* strings of total length [1-9].*/XXXX strings of total length YYYYY/
	s/9 ops out of [1-9][0-9]*/9 ops out of YYY/
	s/TeX output ....\...\...:.../TeX output YYYY.MM.DD:hhmm/
	_EOF
+ cat

# x86 glue rounding
cat >>filter <<-\_EOF
	s/ 16341\.999.*fil/ 16342.0fil/
	s/ 16238\.999.*fil/ 16239.0fil/
	s/ 16317\.999.*fil/ 16318.0fil/
	s/ 16330\.999.*fil/ 16331.0fil/
	s/ 16331\.999.*fil/ 16332.0fil/
	s/ 16343\.999.*fil/ 16344.0fil/
	s/ 9737\.587..fil/ 9737.58789fil/
	s/down4 639342../down4 639342208/
	s/y4 2039217./y4 203921760/
	s/y0 2039217./y0 203921760/
	_EOF
+ cat

dvitype_args="-output-level=2 -dpi=72.27 -page-start='*.*.*.*.*.*.*.*.*.*'"
+ dvitype_args='-output-level=2 -dpi=72.27 -page-start='\''*.*.*.*.*.*.*.*.*.*'\'''

echo ">>> Running TRIP test for TeX." >&2
+ echo '>>> Running TRIP test for TeX.'
>>> Running TRIP test for TeX.
echo ">>> See $testdir/trip.diffs for example of acceptable diffs." >&2
+ echo '>>> See SRCDIR/triptrap/trip.diffs for example of acceptable diffs.'
>>> See SRCDIR/triptrap/trip.diffs for example of acceptable diffs.

is_OK=:
+ is_OK=:

set -x
+ set -x

./pltotf $testdir/trip.pl trip.tfm || exit 1
+ ./pltotf SRCDIR/triptrap/trip.pl trip.tfm

./tftopl ./trip.tfm trip.pl || exit 1
+ ./tftopl ./trip.tfm trip.pl

diff $testdir/trip.pl trip.pl || is_OK=false
+ diff SRCDIR/triptrap/trip.pl trip.pl

# get same filename in log
rm -f trip.tex
+ rm -f trip.tex
$LN_S $testdir/trip.tex . || exit 1
+ ln -s SRCDIR/triptrap/trip.tex .

rm -f trip.fmt
+ rm -f trip.fmt
./tex --progname=initex --ini <$testdir/trip1.in >tripin.fot
+ ./tex --progname=initex --ini
if test ! -s trip.fmt; then
  echo "*** trip.fmt not created by trip1.in, investigate!" >&2
  exit 1
fi
+ test '!' -s trip.fmt
mv trip.log tripin.log || exit 1
+ mv trip.log tripin.log
diff $testdir/tripin.log tripin.log
+ diff SRCDIR/triptrap/tripin.log tripin.log
1c1
< This is TeX, Version 3.141592653 (INITEX)  4 JUL 1776 12:00
---
> This is TeX, Version 3.141592653 (TeX Live 2021/dev) (INITEX)  27 JAN 2021 18:03
3c3
< (trip.tex
---
> (./trip.tex
450,451c450,451
<  (preloaded format=trip 1776.7.4)
< 1326 strings of total length 23633
---
>  (preloaded format=trip 2021.1.27)
> 1372 strings of total length 24645
461c461
< Hyphenation trie of length 273 has 9 ops out of 500
---
> Hyphenation trie of length 273 has 9 ops out of 35111

# May as well test non-ini second time through.
./tex --progname=tex <$testdir/trip2.in >trip.fot
+ ./tex --progname=tex
diff $testdir/trip.fot trip.fot
+ diff SRCDIR/triptrap/trip.fot trip.fot
1,3c1,2
< This is TeX, Version 3.141592653 (INITEX)
< ** &trip  trip 
< (trip.tex ##
---
> This is TeX, Version 3.141592653 (TeX Live 2021/dev) (preloaded format=tex)
> **(./trip.tex ##

# We use $DIFF instead of `diff' only for those files where there
# might actually be legitimate numerical differences.
$DIFF $DIFFFLAGS $testdir/trip.log trip.log
+ diff SRCDIR/triptrap/trip.log trip.log
1c1
< This is TeX, Version 3.141592653 (preloaded format=trip 1776.7.4)  4 JUL 1776 12:00
---
> This is TeX, Version 3.141592653 (TeX Live 2021/dev) (preloaded format=trip 2021.1.27)  27 JAN 2021 18:03
3c3
< (trip.tex ##
---
> (./trip.tex ##
1405c1405
< \vbox(16383.99998+0.0)x1000.0, glue set 16342.0fil
---
> \vbox(16383.99998+0.0)x1000.0, glue set 16341.99998fil
1954c1954
< (tripos.tex
---
> (./tripos.tex
2018c2018
< \vbox(16383.99998+1.0)x100.0, glue set 16239.0fil
---
> \vbox(16383.99998+1.0)x100.0, glue set 16238.99998fil
2533c2533
< \vbox(16383.99998+0.0)x20.0, glue set 16331.0fil
---
> \vbox(16383.99998+0.0)x20.0, glue set 16330.99998fil
3326c3326
< \vbox(10000.0+2.0)x28.0, glue set 9737.58789fil
---
> \vbox(10000.0+2.0)x28.0, glue set 9737.58742fil
3864c3864
< \vbox(16383.99998+2.0)x100.0, glue set 16318.0fil
---
> \vbox(16383.99998+2.0)x100.0, glue set 16317.99997fil
4034c4034
< \vbox(16383.99998+0.0)x8236.0, glue set 16344.0fil
---
> \vbox(16383.99998+0.0)x8236.0, glue set 16343.99998fil
4420c4420
< \vbox(16383.99998+0.0)x100.0, glue set 16332.0fil
---
> \vbox(16383.99998+0.0)x100.0, glue set 16331.99998fil
4742c4742
< \vbox(16383.99998+0.0)x205.12613, glue set 16344.0fil
---
> \vbox(16383.99998+0.0)x205.12613, glue set 16343.99998fil
6381c6381
< (tripos.tex
---
> (./tripos.tex
7297,7298c7297,7298
<  47 strings out of 1674
<  253 string characters out of 8367
---
>  44 strings out of 1628
>  261 string characters out of 15355
7300c7300
<  372 multiletter control sequences out of 2100
---
>  372 multiletter control sequences out of 15000+0
7302c7302
<  2 hyphenation exceptions out of 307
---
>  1 hyphenation exception out of 659

diff $testdir/tripos.tex tripos.tex || is_OK=false
+ diff SRCDIR/triptrap/tripos.tex tripos.tex

eval ./dvitype $dvitype_args trip.dvi >trip.typ || exit 1
+ eval ./dvitype -output-level=2 -dpi=72.27 '-page-start='\''*.*.*.*.*.*.*.*.*.*'\''' trip.dvi
./dvitype -output-level=2 -dpi=72.27 -page-start='*.*.*.*.*.*.*.*.*.*' trip.dvi
++ ./dvitype -output-level=2 -dpi=72.27 '-page-start=*.*.*.*.*.*.*.*.*.*' trip.dvi
$DIFF $DIFFFLAGS $testdir/trip.typ trip.typ
+ diff SRCDIR/triptrap/trip.typ trip.typ
1c1
< This is DVItype, Version 3.6
---
> This is DVItype, Version 3.6 (TeX Live 2021/dev)
9c9
< ' TeX output 1776.07.04:1200'
---
> ' TeX output 2021.01.27:1803'
419c419
< 1121: down4 639342208 
---
> 1121: down4 639342177 
1087,1088c1087,1088
< 2535: y4 203921760 
< 2540: y0 203921760 
---
> 2535: y4 203921756 
> 2540: y0 203921756 

for f in tripin.log trip.fot trip.log trip.typ; do
  sed $testdir/$f -f filter >a/$f
  sed $f -f filter >b/$f
  diff a/$f b/$f || is_OK=false
done
+ for f in tripin.log trip.fot trip.log trip.typ
+ sed SRCDIR/triptrap/tripin.log -f filter
+ sed tripin.log -f filter
+ diff a/tripin.log b/tripin.log
+ for f in tripin.log trip.fot trip.log trip.typ
+ sed SRCDIR/triptrap/trip.fot -f filter
+ sed trip.fot -f filter
+ diff a/trip.fot b/trip.fot
+ for f in tripin.log trip.fot trip.log trip.typ
+ sed SRCDIR/triptrap/trip.log -f filter
+ sed trip.log -f filter
+ diff a/trip.log b/trip.log
+ for f in tripin.log trip.fot trip.log trip.typ
+ sed SRCDIR/triptrap/trip.typ -f filter
+ sed trip.typ -f filter
+ diff a/trip.typ b/trip.typ

$is_OK && {
  echo ">>> All differences are acceptable." >&2
} || {
  echo "*** Error(s) found in trip test, investigate!" >&2
  exit 1
}
+ :
+ echo '>>> All differences are acceptable.'
>>> All differences are acceptable.
PASS triptest.test (exit status: 0)
PASS: triptest.test
